# Test module

#from testing.shortcuts import *
#from twill import commands as tc
from django.test import TestCase


class TestLogIn(TestCase):
	def test_login(self):
		#twill_quiet()
		tc.go("http://127.0.0.1:8000/accounts/login")
		tc.fv('1', 'username', 'admin')
		tc.fv('1', 'password', 'admin')
		tc.submit()
		tc.find("Bienvenido")
		tc.find("admin")
		tc.go("http://127.0.0.1:8000/accounts/logout")
		
	def test_login_failed(self):
		#twill_quiet()
		tc.go("http://127.0.0.1:8000/accounts/login")
		tc.fv('1', 'username', 'admin')
		tc.fv('1', 'password', 'mal')
		tc.submit()
		tc.notfind("Bienvenido")
		
	def test_logout(self):
		#twill_quiet()
		tc.go("http://127.0.0.1:8000/accounts/login")
		tc.fv('1', 'username', 'admin')
		tc.fv('1', 'password', 'admin')
		tc.submit()
		tc.go("http://127.0.0.1:8000/accounts/logout")
		tc.find("Gracias")
		
	def test_change_password(self):
		#twill_quiet()
		tc.go("http://127.0.0.1:8000/accounts/login")
		tc.fv('1', 'username', 'admin')
		tc.fv('1', 'password', 'admin')
		tc.submit()
		tc.go("http://127.0.0.1:8000/accounts/password_change/")
		tc.fv('1', 'old_password', 'admin')
		tc.fv('1', 'new_password1', 'admin2')
		tc.fv('1', 'new_password2', 'admin2')
		tc.submit()
		tc.go("http://127.0.0.1:8000/accounts/logout")
		tc.go("http://127.0.0.1:8000/accounts/login")
		tc.fv('1', 'username', 'admin')
		tc.fv('1', 'password', 'admin2')
		tc.submit()
		tc.find("Bienvenido")
		tc.go("http://127.0.0.1:8000/accounts/password_change/")
		tc.fv('1', 'old_password', 'admin2')
		tc.fv('1', 'new_password1', 'admin')
		tc.fv('1', 'new_password2', 'admin')
		tc.submit()
		tc.go("http://127.0.0.1:8000/accounts/logout")
		





class Test(TestCase):
	def test_login(self):
		twill_quiet()
		tc.go("http://127.0.0.1:8000/accounts/login")
		tc.fv('1', 'username', 'admin')
		tc.fv('1', 'password', 'admin')
		tc.submit()
		tc.find("Bienvenido")
		tc.find("admin")
		
	def test_logout(self):
		twill_quiet()
		tc.go("http://127.0.0.1:8000/accounts/login")
		tc.fv('1', 'username', 'admin')
		tc.fv('1', 'password', 'admin')
		tc.submit()
		tc.go("http://127.0.0.1:8000/accounts/logout")
		tc.find("Gracias")

		
		
		
		
